<?php

class FaqModule extends fvModule {

    function __construct () {
        $moduleName = strtolower(substr(__CLASS__, 0, -6));

        parent::__construct(fvSite::$fvConfig->get("modules.{$moduleName}.smarty.template"), 
                            fvSite::$fvConfig->get("modules.{$moduleName}.smarty.compile"), 
                            fvSite::$Layoult);
    }

    function showIndex() {
        $pager = new fvPager(FaqManager::getInstance());
        $this->__assign('Faqs', $pager->paginate(null, 'create_date DESC'));
        return $this->__display('faq_list.tpl');    
    }

    function showEdit() {
        $request = fvRequest::getInstance();
        if (!$Faq = FaqManager::getInstance()->getByPk($request->getRequestParameter('id'))) {
            $Faq = new Faq();
        }
        $editor = new fvCKEditor();
        $this->__assign(array(
            'Faq' => $Faq,
            'editor' => $editor->editor("n[answer]", "n_answer", $Faq->answer),
        	'LoggedUser' => fvSite::$fvSession->getUser("login/loggedUser"),
        ));
        return $this->__display('faq_edit.tpl');
    }
    
}

?>
